package com.repeat.member.mq.produc;

import com.repeat.member.config.RabbitFanoutConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class UserProduct {
    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void produce(String queueName, String message) {
        rabbitTemplate.convertAndSend(queueName, message);
    }

    //广播消息
    public void FanoutProduce(String message) {
        rabbitTemplate.convertAndSend(RabbitFanoutConfig.EXCHANGE_NAME, "",message);
    }
    //路由消息
    public void DirectProduce(String key,String message) {
        rabbitTemplate.convertAndSend("shop.direct_exchange", key, message);
    }
}
